﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using DevExpress.XtraBars.Ribbon;
using Newtonsoft.Json;

namespace HouseSecretary.HouseForm
{
    public partial class HouseSrcInfoWebDCLookDlgForm : Base.DlgForm
    {
        public HouseSrcInfoWebDCLookDlgForm(Model.CommonDlgParameters CommonDlgParametersModel)
        {
            InitializeComponent();
            commonDlgParameters = CommonDlgParametersModel;
        }
        Model.CommonDlgParameters commonDlgParameters = new Model.CommonDlgParameters();
        string HouseSrcInfoID = "";

        private void HouseSrcInfoWebDCLookDlgForm_Load(object sender, EventArgs e)
        {
            HouseSrcInfoID = commonDlgParameters.StringList[0];//获取房源编号
            //根据ID获取房源（需要API程序）
            string strJson = "[";
            strJson += "{'FHouseSrcInfoID':'1','FTitle':'天一好景60平方3室1厅1卫','FDCSource':'58同城','FRentSale':'C','FDistrictNo4':'海曙区','FAddr':'天一好景','FArea':'50','DoorModel':'3室1厅1卫','FDCDate':'2015-02-09 09:48:07.780','FPrice':'600000','FStatus':'2','FFloor':'2','FTotalFloor':'5','FLookCnt':'8','FIsTelText':'Y','FHouseOwnerTelText':'13895689511','FHouseOwner':'包房东','FWebRegDate':'2015-02-09 09:48:07.780','FNote':'地处商业中心，购物方便\r\n阳光充足，环境优美'},";
            strJson = strJson.Trim(',');
            strJson += "]";


            List<Model.HouseSrcInfoWebDC> HouseSrcList = JsonConvert.DeserializeObject<List<Model.HouseSrcInfoWebDC>>(strJson);

            if (HouseSrcList.Count > 0)
            {
                //加载房源明细控件
                Model.CommonDlgParameters commDlgParam = new Model.CommonDlgParameters();
                commDlgParam.QueryModelList.Add(HouseSrcList[0]);
                HouseSrcInfoWebDCLookCtrl.HouseSrcInfoWebDCLook_BasicControl LookBasicControl = new HouseSrcInfoWebDCLookCtrl.HouseSrcInfoWebDCLook_BasicControl(commDlgParam);
                LookBasicControl.Dock = DockStyle.Fill;
                this.xtraTabPage1.Controls.Add(LookBasicControl);

                //入库、取消、关闭等按钮
                if (HouseSrcList[0].FStatus == "2")//已入库，显示关闭；未入库，显示入库、取消
                {
                    this.btnOk.Visible = false;
                    this.btnCancel.Text = "关闭";
                    this.btnCancel.Left = this.Width / 2 - this.btnCancel.Width / 2;//关闭按钮居中显示
                }


            }




            //房源图片
            
            int houseImgCount = 1;
            if (houseImgCount > 0)
            {
                for (int i = 0; i < houseImgCount; i++)
                {
                    GalleryItem glyItem = new GalleryItem();
                    glyItem.Caption = "图片加载中...";
                    galleryStyleImg.Gallery.Groups[0].Items.Add(glyItem);
                }
            }
            else
            {
                xtraTabPage2.PageVisible = false;
            }


        }

        private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e)
        {

        }

        private void backgroundWorker1_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
        {

        }

        private void btnOk_Click(object sender, EventArgs e)
        {
            this.DialogResult = DialogResult.OK;
        }





    }
}
